<?php

namespace App\Console\Commands;
use AlibabaCloud\SDK\Bailian\V20231229\Models\ApplyFileUploadLeaseRequest;
use AlibabaCloud\SDK\Bailian\V20231229\Models\DeleteIndexDocumentRequest;
use AlibabaCloud\SDK\Bailian\V20231229\Models\SubmitIndexAddDocumentsJobRequest;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
use App\Jobs\Test;
use App\Services\BaiLian\BaiLianService;
use Dompdf\Dompdf;

use Illuminate\Console\Command;
use Illuminate\Http\File;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
use League\Flysystem\Config;
use League\Flysystem\Visibility;
use OSS\OssClient;
use PhpOffice\PhpWord\IOFactory;

class test1 extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 't1';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Execute the console command.
     */
    public function handle(
        SubmitIndexAddDocumentsJobRequest $request,
        RuntimeOptions $runtimeOptions
    )
    {
//        file_exists('')
         # 1 question
         # 2 获取用户 数据（做题记录|老师数据）
         # 2.5 有时间做 把数据md5 去数据库中找 有相似直接返回id。
         # 3 把数据上传到 baiLian 获取文件id
         # 4 把文件追加到知识库
         # 5 调用api 发起提问 问题内容是 1中的question，提问时制定知识库和文件id


         $client = BaiLianService::createClient();
         $workSpaceId = 'llm-73j8yibq789jomrv';
         $request->indexId = 'dfykgpt2nh';
         $request->sourceType = 'DATA_CENTER_FILE';
         $request->documentIds = ['file_b2b66566fdd54501a9d741fe754eafef_10341754'];
//         $request->categoryIds = ['file_b2b66566fdd54501a9d741fe754eafef_10341754'];
         $res = $client->submitIndexAddDocumentsJobWithOptions($workSpaceId,$request,[],$runtimeOptions);
//         $client->applyFileUploadLease($workSpaceId,)
        $c = 1;
    }

    public function getQuestion()
    {
        return '3000以下的手机有哪些';
    }

    public function getRagData()
    {
        return [

        ];
    }

    public function uploadFileToBaiLian()
    {
        $request = new ApplyFileUploadLeaseRequest();
        $request->fileName = 'dfykgpt2nh';
        $request->md5 = md5_file($request->fileName);
        $request->sizeInBytes = '';

    }

    public function submitIndexAddDocumentsJob()
    {

    }

    public function answer()
    {

    }
}
